package unicall.em.models;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Table;

import unicall.em.base.BaseModel;
import unicall.em.dtos.MediaDto;

@Entity
@Table(name="CC_MEDIA")
public class Media extends BaseModel {
    //名称
    private String name;
    //类型
    private String category;
    //云之讯平台唯一标识
    private String fileId;
    //名称
    private String fileName;
    //审核时间
    private String auditedAt;
    //审核结果
    private String auditResult;
    //审核原因
    private String reason;
    //状态
    private String state;
    //文件在第三方平台的名字
    private String fileAliasName;
    
    public Media(){
        this.setStatus(STATUS.USE.getValue());
        this.state = State.READY.getState();
        this.setCreatedAt( new Date());
        this.setUpdatedAt(new Date());    
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getFileId() {
        return fileId;
    }

    public void setFileId(String fileId) {
        this.fileId = fileId;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getAuditedAt() {
        return auditedAt;
    }

    public void setAuditedAt(String auditedAt) {
        this.auditedAt = auditedAt;
    }



    public String getAuditResult() {
        return auditResult;
    }

    public void setAuditResult(String auditResult) {
        this.auditResult = auditResult;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }
    
    
    
    public String getFileAliasName() {
        return fileAliasName;
    }

    public void setFileAliasName(String fileAliasName) {
        this.fileAliasName = fileAliasName;
    }

    public MediaDto toDto(){
        MediaDto dto = new MediaDto();
        dto.setId(this.getId());
        dto.setTenantId(this.getTenantId());
        dto.setName(this.getName());
        dto.setFileName(this.getFileName());
        dto.setFileId(this.getFileId());
        dto.setCategory(this.getCategory());
        dto.setAuditedAt(this.getAuditedAt());
        dto.setAuditResult(this.getAuditResult());
        dto.setReason(this.getReason());
        dto.setCreatorId(this.getCreatorId());
        dto.setCreatedAt(this.getCreatedAt());
        dto.setUpdatedAt(this.getUpdatedAt());
        dto.setOperatorId(this.getOperatorId());
        dto.setState(this.getState());
        dto.setFileName(this.fileName);
        dto.setFileAliasName(this.getFileAliasName());
        return dto;
    }
    
   public enum State{
        READY("ready"),RSYNC("rsync"),ERROR("error"),READYAUDIT("readyAudit"),NOTPASS("notPass"),PASS("pass");
        private  String name;
        private State(String name){
            this.name = name;
        }
       public String getState(){
           return this.name;
       }
    }
}
